package com.zhku.laosiji.service.Impl;

import com.zhku.laosiji.dao.AdminMapper;
import com.zhku.laosiji.pojo.Admin;
import com.zhku.laosiji.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by LINWENHAO on 2018/9/11.
 */
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin selectByName(String name) {
        return adminMapper.selectByName(name);
    }

    @Override
    public int updateAdmin(Admin admin) {
        return adminMapper.updateByPrimaryKey(admin);
    }
        @Override
    public List<Admin> getAdminList(){
       return adminMapper.queryAdmin();
    }

    @Override
    public int addAdmin(Admin admin) {
        admin.setCreatedate(new Date());
        return adminMapper.insert(admin);
    }

    @Override
    public List<Admin> selectAdminByName(String name) {
        return adminMapper.selectByNameLike(name);
    }

    @Override
    public List<Admin> selectAdminByNameLike(String name) {
        return adminMapper.selectByNameLike(name);

    }

    @Override
    public int deleteAdmin(Integer id) {
        return adminMapper.deleteByPrimaryKey(id);
    }
}
